package com.linkstec;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StringTest {
	private static final Logger logger = LoggerFactory.getLogger(StringTest.class);

	public static void main(String[] args) {
		String str1 = "helloWorld";
		str1 = "helloWorld222";
		System.out.println(str1);
		String str2 = "hello" + "World";
		String str3 = "hello";
		String str4 = "World";
		String str5 = str3 + str4;
		System.out.println(str1.equals(str2));
		System.out.println(str1.equals(str5));
		
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");

		String trdDate = "20170309";
		String trdTime = "133018";
		String time = trdDate.substring(0, 4) + "-" + trdDate.substring(4, 6) + "-" + trdDate.substring(6, 8)
		              + " " + trdTime.substring(0, 2) + ":" + trdTime.substring(2, 4);
		System.out.println(time);
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		String fundId = "123455678";
		String secret = fundId.replaceAll("(?<=\\d{0})\\d(?=\\d{3})", "*");
		System.out.println(secret);
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		int yourNumber = 82830;
		String mmm = String.format("%06d", yourNumber);
		System.out.println(mmm);
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		String alarm = "12345644444";
		String aaa = alarm.length() > 5 ? alarm.substring(0,5) : alarm;
		System.out.println(aaa);
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		String custCode = "03000001111223";
		System.out.println(custCode.startsWith("03"));
		if (custCode.startsWith("03")) {
			custCode = custCode.substring(2, custCode.length());
			System.out.println(custCode);
			int iii = Integer.parseInt(custCode);
			custCode = Integer.toString(iii);
			System.out.println(iii);
			System.out.println(custCode);
		}
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
//		String cuacctCode = "0300000001123123123";
		String cuacctCode = "0300001";
		if (cuacctCode.startsWith("03") && cuacctCode.length() > 6) {
			cuacctCode = cuacctCode.substring(6, cuacctCode.length());
			System.out.println(cuacctCode);
		}
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		String sss = "11111113";
		sss = getStarString(sss, 1, 1);
		System.out.println(sss);
		System.out.println("++++++++++++++++++++++++++++++++++++++++++");
		String ss = "HQ002|SZ|20170907-10:41:54.000|002833|弘亚数控|780339|45875855.760|57.860|57.840|59.500|57.440|58.830||58.820|400|58.830|400|58.810|300|58.850|400|58.800|1400|58.870|1500|58.710|100|58.890|2007|58.700|300|58.910|100|||||||||||||";
		String[] sss11 = ss.split("\\|");
		System.out.println(ss.contains("|"));
		logger.info(sss11.toString());
		logger.info("fff");
		logger.info("fff" + null);
		logger.info("fff");
		
		String ssssss = "	12  3 "; 
		logger.info(ssssss.trim());
		
		
	}
	private static String getStarString(String content, int frontNum, int endNum) {
		
        if (frontNum >= content.length() || frontNum < 0) {
            return content;
        }
        if (endNum >= content.length() || endNum < 0) {
            return content;
        }
        if (frontNum + endNum >= content.length()) {
            return content;
        }
        String starStr = "";
        for (int i = 0; i < (content.length() - frontNum - endNum); i++) {
            starStr = starStr + "*";
        }
        return content.substring(0, frontNum) + starStr
                + content.substring(content.length() - endNum, content.length());
    }
}
